package com.ruoyi.develop.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.domain.NewMemberDevelop;
import com.ruoyi.develop.service.INewMemberDevelopService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 新团员发展Controller
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/develop/develop")
public class NewMemberDevelopController extends BaseController
{
    @Autowired
    private INewMemberDevelopService newMemberDevelopService;

    /**
     * 查询新团员发展列表
     */
    @PreAuthorize("@ss.hasPermi('develop:develop:list')")
    @GetMapping("/list")
    public TableDataInfo list(NewMemberDevelop newMemberDevelop)
    {
        startPage();
        List<NewMemberDevelop> list = newMemberDevelopService.selectNewMemberDevelopList(newMemberDevelop);
        return getDataTable(list);
    }

    /**
     * 导出新团员发展列表
     */
    @PreAuthorize("@ss.hasPermi('develop:develop:export')")
    @Log(title = "新团员发展", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NewMemberDevelop newMemberDevelop)
    {
        List<NewMemberDevelop> list = newMemberDevelopService.selectNewMemberDevelopList(newMemberDevelop);
        ExcelUtil<NewMemberDevelop> util = new ExcelUtil<NewMemberDevelop>(NewMemberDevelop.class);
        util.exportExcel(response, list, "新团员发展数据");
    }

    /**
     * 获取新团员发展详细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:develop:query')")
    @GetMapping(value = "/{nmdId}")
    public AjaxResult getInfo(@PathVariable("nmdId") Long nmdId)
    {
        return success(newMemberDevelopService.selectNewMemberDevelopByNmdId(nmdId));
    }

    /**
     * 新增新团员发展
     */
    @PreAuthorize("@ss.hasPermi('develop:develop:add')")
    @Log(title = "新团员发展", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NewMemberDevelop newMemberDevelop)
    {
        SysUser user= SecurityUtils.getLoginUser().getUser();
        newMemberDevelop.setDeptId(105L);
        newMemberDevelop.setUserId(user.getUserId());
        return toAjax(newMemberDevelopService.insertNewMemberDevelop(newMemberDevelop));
    }

    /**
     * 修改新团员发展
     */
    @PreAuthorize("@ss.hasPermi('develop:develop:edit')")
    @Log(title = "新团员发展", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NewMemberDevelop newMemberDevelop)
    {
        return toAjax(newMemberDevelopService.updateNewMemberDevelop(newMemberDevelop));
    }

    /**
     * 删除新团员发展
     */
    @PreAuthorize("@ss.hasPermi('develop:develop:remove')")
    @Log(title = "新团员发展", businessType = BusinessType.DELETE)
	@DeleteMapping("/{nmdIds}")
    public AjaxResult remove(@PathVariable Long[] nmdIds)
    {
        return toAjax(newMemberDevelopService.deleteNewMemberDevelopByNmdIds(nmdIds));
    }
}
